{extend name="common:base" /}

{block name="page_title"}{$controllerName}添加{/block}

{block name="content"}
<div class="box">
    <div class="box-header with-border"></div>
    <form class="form-horizontal ajaxForm3" name="form0" method="post" action="{:url('')}">
        <div class="box-body">
            {volist name="formFields" id="v"}
            {switch $v['type']}
            {case hidden}
            {if ('id' == $v['name'])}
            <input type="hidden" name="{$v['name']}" value="0">
            {else /}
            <input type="hidden" name="{$v['name']}" value="">
            {/if}
            {/case}
            {case text}
            <div class="form-group">
                <label class="col-sm-2 control-label">{$v['text']}</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="{$v['name']}" placeholder="{$v['text']}">
                    {if(!empty($v['explain']))}
                    <p class="help-block">{$v['explain']}</p>
                    {/if}
                </div>
            </div>
            {/case}
            {case textarea}
            <div class="form-group">
                <label class="col-sm-2 control-label">{$v['text']}</label>
                <div class="col-sm-10">
                    <textarea type="text" class="form-control" name="{$v['name']}" placeholder="{$v['text']}"></textarea>
                    {if(!empty($v['explain']))}
                    <p class="help-block">{$v['explain']}</p>
                    {/if}
                </div>
            </div>
            {/case}
            {case image_select}
            <div class="form-group">
                <label class="col-sm-2 control-label">{$v['text']}</label>
                <div class="col-sm-10">
                    <input id="image_select_{$v['name']}" type="file">
                    <input type="hidden" class="image_select_hidden" name="{$v['name']}" id="h_{$v['name']}" text="{$v['text']}">
                    {if(!empty($v['explain']))}
                    <p class="help-block">{$v['explain']}</p>
                    {/if}
                </div>
            </div>
            {/case}
            {case password}
            <div class="form-group">
                <label class="col-sm-2 control-label">{$v['text']}</label>
                <div class="col-sm-10">
                    <input type="password" class="form-control" name="{$v['name']}" placeholder="{$v['text']}">
                    {if(!empty($v['explain']))}
                    <p class="help-block">{$v['explain']}</p>
                    {/if}
                </div>
            </div>
            {/case}
            {case radio}
            <div class="form-group">
                <label class="col-sm-2 control-label">{$v['text']}</label>
                <div class="col-sm-10">
                    <input type="radio" class="form-control" name="{$v['name']}" placeholder="{$v['text']}">
                    {if(!empty($v['explain']))}
                    <p class="help-block">{$v['explain']}</p>
                    {/if}
                </div>
            </div>
            {/case}
            {case value="select|select_empty"}
            <div class="form-group">
                <label class="col-sm-2 control-label">{$v['text']}</label>
                <div class="col-sm-10">
                    <select name="{$v['name']}" class="form-control">
                        {if('select_empty' == $v['type'])}
                        <option value="0">请选择</option>
                        {/if}
                        <?php echo(getSelectHtml($v)); ?>
                    </select>
                    {if(!empty($v['explain']))}
                    <p class="help-block">{$v['explain']}</p>
                    {/if}
                </div>
            </div>
            {/case}
            {case select_source}
            <div class="form-group">
                <label class="col-sm-2 control-label">{$v['text']}</label>
                <div class="col-sm-10">
                    {if(!empty($v['type_value_custom']) && (!empty($v['type_value_custom']['source'])))}
                    <select name="{$v['name']}" class="form-control">
                        <?php echo(getSelectHtml($v,'',$selectList[$v['type_value_custom']['source']])); ?>
                    </select>
                    {if(!empty($v['explain']))}
                    <p class="help-block">{$v['explain']}</p>
                    {/if}
                    {else/}
                    配置错误
                    {/if}
                </div>
            </div>
            {/case}
            {case value="umeditor"}
            <div class="form-group">
                <label class="col-sm-2 control-label">{$v['text']}</label>
                <div class="col-sm-10">
                    <textarea type="text" name="{$v['name']}" class="form-control nd-umeditor" id="umeditor_{$v['name']}"></textarea>
                    {if(!empty($v['explain']))}
                    <p class="help-block">{$v['explain']}</p>
                    {/if}
                </div>
            </div>
            {/case}
            {/switch}
            {/volist}
        </div>
        <!-- /.box-body -->
        <div class="box-footer">
            <div class="row">
                <div class="col-xs-2"></div>
                <div class="col-xs-10">
                    <button type="submit" class="btn btn-info ladda-button" data-style="expand-left" data-plugin="ladda">
                        <span class="ladda-label"><i class="icon wb-arrow-expand margin-right-10" aria-hidden="true"></i>提交</span>
                    </button>
                    <a href="javascript:history.go(-1);" class="btn btn-default">返回</a>
                </div>
            </div>
        </div>
        <!-- /.box-footer -->
    </form>
</div>
{/block}

{block name="script"}
{volist name="formFields" id="v"}
{switch $v['type']}
{case image_select}
<script>
    var fn_image_select_{$v['name']} = function () {
        if(!window['gdbase']){
            console.log('等待加载...');
            setTimeout(fn_image_select_{$v['name']},500);
            return;
        }
        gdbase.initFileInput("#image_select_{$v['name']}","#h_{$v['name']}",false,function (data, previewId, index) {
            console.log(data);
            if(data['code']){
                $("#h_{$v['name']}").val(data['data']['url']);
            }
        })
    }
    fn_image_select_{$v['name']}();
</script>
{/case}
{case value="umeditor"}
<script>
    var fn_umeditor_{$v['name']} = function () {
        if(!window['gdbase']){
            console.log('等待加载...');
            setTimeout(fn_umeditor_{$v['name']},500);
            return;
        }
        gdbase.initUmEditor('.nd-umeditor');
    }
    fn_umeditor_{$v['name']}();
</script>
{/case}
{/switch}
{/volist}
{/block}